<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id')->comment('用户id');
            $table->tinyInteger('order_type')->comment("订单类型 1：普通订单  2：团购订单  3：秒杀订单");
            $table->bigInteger('address_id')->comment('收货信息');
            $table->decimal('postage',10,2)->comment('运费');
            $table->decimal('order_amount',10,2)->comment('订单金额');
            $table->decimal('payment',10,2)->comment('实付金额');
            $table->bigInteger('coupon_id')->comment('优惠券 -1：不使用优惠券');
            $table->tinyInteger('payment_type')->default(1)->comment('支付类型 1：微信支付  2：余额支付');
            $table->tinyInteger('status')->comment('订单状态 1：待付款 2：待发货 3：已发货 4：订单完成 5：订单取消 6：订单进行中 7:订单已失效');
            $table->timestamp('pay_time')->nullable()->comment('支付时间');
            $table->timestamp('send_time')->nullable()->comment('发货时间');
            $table->timestamp('end_time')->nullable()->comment('订单完成时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
